/*
 * @Author: Libra
 * @Date: 2021-09-18 16:44:51
 * @LastEditTime: 2022-01-22 16:01:21
 * @LastEditors: Libra
 * @Description: 阅卷管理api
 * @FilePath: /stone-admin-ui/src/api/review.js
 */

import request from '@/utils/request'
import { REPORT_HOST, SUPER_MANAGE_HOST, REVIEW_HOST } from './server'
import axios from 'axios'

/**
 * 阅卷开始
 * @param {*} data
 */
export function startReview(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/start/${taskUuid}`,
    method: 'GET'
  })
}

/**
 * 可阅卷的职位列表
 */
export function reviewJobList() {
  return request({
    url: `${REPORT_HOST}/review/admin/job/list`,
    method: 'GET'
  })
}
/**
 * 阅卷官列表
 */
export function reviewerList() {
  return request({
    url: `${SUPER_MANAGE_HOST}/operator/review/list`,
    method: 'GET'
  })
}
/**
 * 更新阅卷任务
 */
export function updateReviewTask(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/update`,
    method: 'POST',
    data
  })
}
/**
 * 阅卷考生基本信息
 */
export function reviewCandidateInfo(data) {
  return request({
    url: `${REPORT_HOST}/review/candidate/detail`,
    method: 'POST',
    data
  })
}
/**
 * 添加阅卷官
 */
export function addOperator(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/operator/init`,
    method: 'POST',
    data
  })
}
/**
 * 添加阅卷官
 */
export function add(data) {
  return request({
    url: `${SUPER_MANAGE_HOST}/operator/review/add`,
    method: 'POST',
    data
  })
}
/**
 * 调整阅卷考生数量
 */
export function updateCandidateCount(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/operator/candidate/change`,
    method: 'POST',
    data
  })
}
/**
 * 阅卷任务列表
 */
export function reviewTasks() {
  return request({
    url: `${REVIEW_HOST}/review/operator/task/list`,
    method: 'GET'
  })
}
/**
 * 删除阅卷官
 */
export function deleteOperator(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/operator/remove`,
    method: 'POST',
    data
  })
}
/**
 * 导出阅卷官
 */
export function exportOperator(data) {
  return request({
    url: `${SUPER_MANAGE_HOST}/operator/review/download`,
    method: 'POST',
    responseType: 'blob',
    data
  })
}
/**
 * 同步阅卷
 */
export function syncReview(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/sync/${taskUuid}`,
    method: 'GET'
  })
}
/*
 * 阅卷考生列表
 */
export function reviewCandidateList(reviewOperatorUuid) {
  return request({
    url: `${REVIEW_HOST}/review/candidate/list/${reviewOperatorUuid}`,
    method: 'GET'
  })
}
/**
 * 阅卷判分
 */
export function judge(data) {
  return request({
    url: `${REVIEW_HOST}/review/judge`,
    method: 'POST',
    data
  })
}
/**
 * 下一个考生
 */
export function nextCandidate(data) {
  return request({
    url: `${REVIEW_HOST}/review/next/candidate/uuid`,
    method: 'POST',
    data
  })
}
/**
 * 上一个考生
 */
export function preCandidate(data) {
  return request({
    url: `${REVIEW_HOST}/review/previous/candidate/uuid`,
    method: 'POST',
    data
  })
}
/**
 * 考生阅卷结果
 */
export function judgeResult(data) {
  return request({
    url: `${REVIEW_HOST}/review/judge/result`,
    method: 'POST',
    data
  })
}
/**
 * 修改个人信息
 */
export function updateInfo(data) {
  return request({
    url: `${SUPER_MANAGE_HOST}/operator/update/mobile`,
    method: 'POST',
    data
  })
}
/**
 * 修改姓名
 */
export function updateName(data) {
  return request({
    url: `${REVIEW_HOST}/review/operator/rename`,
    method: 'POST',
    data
  })
}
/**
 * 结束阅卷任务
 */
export function finishReview(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/finish/${taskUuid}`,
    method: 'GET'
  })
}
/**
 * 获取任务info
 */
export function getTaskInfoOp(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/task/info/${taskUuid}`,
    method: 'GET'
  })
}

/**
 * 下载阅卷任务
 */
export function download_video(url) {
  return axios.request({
    url: `${url}`,
    method: 'GET',
    responseType: 'blob'
  })
}
/**
 * 阅卷任务列表
 */
export function reviewTaskList(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/page`,
    method: 'POST',
    data
  })
}
/**
 * 下载阅卷任务
 */
export function downloadReviewTask(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/excel/task/${taskUuid}`,
    method: 'GET',
    responseType: 'blob'
  })
}
/**
 * 删除阅卷任务
 */
export function deleteReviewTask(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/remove/${taskUuid}`,
    method: 'GET'
  })
}
/**
 * 获取所有试题
 */
export function getQusetionList(data) {
  return request({
    url: `${REPORT_HOST}/review/admin/task/select/question`,
    method: 'POST',
    data
  })
}
/**
 * 获取阅卷人数范围
 */
export function getSelectQuantity(data) {
  return request({
    url: `${REPORT_HOST}/review/admin/task/select/quantity`,
    method: 'POST',
    data
  })
}
/**
 * 新建阅卷任务
 */
export function addReviewTask(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/add`,
    method: 'POST',
    data
  })
}
/**
 * 阅卷官列表
 */
export function reviewList(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/operator/list`,
    method: 'POST',
    data
  })
}
/**
 * 任务详情
 */
export function getTaskInfo(taskId) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/info/${taskId}`,
    method: 'GET'
  })
}
/**
 * 阅卷职位详情
 */
export function reviewJobInfo(jobUuid) {
  return request({
    url: `${REPORT_HOST}/review/admin/job/info/${jobUuid}`,
    method: 'GET'
  })
}
/**
 * 所有试题
 */
export function taskQuestionList(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/question/list/${taskUuid}`,
    method: 'GET'
  })
}
/**
 * 阅卷明细表
 */
export function taskSchedule(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/schedule`,
    method: 'POST',
    data
  })
}
/**
 * 批量制定阅卷任务
 */
export function taskAssign(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/assign`,
    method: 'POST',
    data
  })
}
/**
 * 任务是否都分配完成
 */
export function taskComplete(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/complete`,
    method: 'POST',
    data
  })
}
/**
 * 获取阅卷官任务进度
 */
export function getOperatorComplete(reviewOperatorUuid) {
  return request({
    url: `${REVIEW_HOST}/review/operator/complete/${reviewOperatorUuid}`,
    method: 'GET'
  })
}
/**
 * 获取阅卷官对应考生的试题
 */
export function candidateQuestion(data) {
  return request({
    url: `${REVIEW_HOST}/review/candidate/question`,
    method: 'POST',
    data
  })
}
/**
 * 获取考生答题答案
 */
export function getAnserList(data) {
  return request({
    url: `${REPORT_HOST}/view/report/candidate/answer`,
    method: 'POST',
    data
  })
}
/** 上一个or下一个考生 */
export function around(data) {
  return request({
    url: `${REVIEW_HOST}/review/candidate/around`,
    method: 'POST',
    data
  })
}
/**
 * 批量给没有作答的题目零分
 */
export function fillZero(data) {
  return request({
    url: `${REVIEW_HOST}/review/fill/zero`,
    method: 'POST',
    data
  })
}
/**
 * 获取分配进度
 */
export function getAllocationProgress(taskUuid) {
  return request({
    url: `${REVIEW_HOST}/review/admin/task/progress/${taskUuid}`,
    method: 'GET'
  })
}
/**
 * 下载 阅卷进度(excel)
 */
export function excelTask(data) {
  return request({
    url: `${REVIEW_HOST}/review/admin/excel/task`,
    method: 'POST',
    responseType: 'blob',
    data
  })
}

/**
 * 获取试卷列表(机考)
 */

export function getPeriodList() {
  return request({
    url: `${REPORT_HOST}/review/admin/period/list`,
    method: 'get'
  })
}

/**
 * 获取试题(机考)
 */
export function getOfflineQuestionList(subjectId) {
  return request({
    url: `${REPORT_HOST}/review/admin/subject/select/question/${subjectId}`,
    method: 'get'
  })
}
/**
 * 获取考生(机考)
 */
export function getOfflineCandidateList(subjectId, count) {
  return request({
    url: `${REPORT_HOST}/review/admin/subject/select/candidate/${subjectId}/${count}`,
    method: 'get'
  })
}
/**
 * 获取考生答案(线下)
 */
export function getOfflineCandidateAnswer(data) {
  return request({
    url: `${REVIEW_HOST}/review/offline/candidate/answer`,
    method: 'post',
    data
  })
}

/**
 * 线下机考科目详情
 */
export function subjectInfoOffline(periodId, subjectId) {
  return request({
    url: `${REVIEW_HOST}/review/offline/subject/${periodId}/${subjectId}`,
    method: 'get'
  })
}
